﻿

<CnGalWebSite.Components.Containers.MasaTitleContainer Icon="@IconType.Home.ToIconString()" Title="主要信息" Class="@Class" Collapable>
    <MRow>
        <MCol Cols="12" Md="6" Lg="4">
            <CnGalWebSite.Components.Images.UploadButton ShowCropper @bind-ImagePath="@Model.MainPicture" Type="ImageAspectType._16_9" Text="上传主图" Class="mb-4" />
         </MCol>
         <MCol Cols="12" Md="6" Lg="4">
             <CnGalWebSite.Components.Images.UploadButton @bind-ImagePath="@Model.BackgroundPicture" Type="ImageAspectType.None" Text="上传大背景图" Class="mb-4" />
         </MCol>
         <MCol Cols="12" Md="6" Lg="4">
             <CnGalWebSite.Components.Images.UploadButton @bind-ImagePath="@Model.SmallBackgroundPicture" Type="ImageAspectType.None" Text="上传小背景图" Class="mb-4" />
         </MCol>
         <MCol Cols="12">
         </MCol>
         <MCol Cols="12" Md="6">
             <MTextField @bind-Value="Model.Type" Label="类别" />
         </MCol>
         <CnGalWebSite.Shared.MasaComponent.Shared.Editors.Cards.DisplayNameCard @bind-Name="Model.Name" @bind-DisplayName="Model.DisplayName" Class="form-group col-12 col-sm-6" />

         <MCol Cols="12">
             <MTextarea Rows="3" @bind-Value="Model.BriefIntroduction" Label="简介" />
         </MCol>
         <MCol Cols="12" Md="6">
             <MTextField Value="_duration" TValue="string" ValueChanged="DurationChanged" Label="时长" />
         </MCol>
         <MCol Cols="12" Md="6">
             <CnGalWebSite.Components.Inputs.MasaDatePicker @bind-Value="Model.PubishTime" ShowDate ShowTime Nullable="false" Label="发布时间" />
         </MCol>
         <MCol Cols="12" Md="6">
             <MCheckbox @bind-Value="Model.IsInteractive" Label="互动视频" TValue="bool" />
         </MCol>
         <MCol Cols="12">
         </MCol>
         <MCol Cols="12" Md="6">
             <CnGalWebSite.Components.Inputs.MasaSelecte @bind-Value="Model.Copyright" TValue="CopyrightType" Label="版权" />
         </MCol>


         <MCol Cols="12" Md="6">
             <MTextField @bind-Value="Model.OriginalAuthor" Label="原作者" />
         </MCol>
         <MCol Cols="12" Md="6">
             <MCheckbox @bind-Value="Model.IsCreatedByCurrentUser" Label="本人创作" TValue="bool" />
         </MCol>
     </MRow>
 </CnGalWebSite.Components.Containers.MasaTitleContainer>

 @code {
    [Parameter]
    public EditVideoMainViewModel Model { get; set; }
    [Parameter]
    public string Class { get; set; }

    string _duration;

    protected override void OnInitialized()
    {
        _duration = Model.Duration.ToString("hh\\:mm\\:ss");
    }

    private void DurationChanged(string ts)
    {
        _duration = ts;
        if(TimeSpan.TryParse(ts, out TimeSpan result))
        {
            Model.Duration = result;
        }
    }
}
